home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 398 < prev    next >
Internet Message Format  |  1996-08-06  |  1KB

  1. Path: solon.com!not-for-mail
  2. From: diamond@tko.dec.com (Norman Diamond)
  3. Newsgroups: comp.std.c,comp.lang.c.moderated
  4. Subject: Re: Integral promotion.
  5. Date: 15 Feb 1996 08:46:03 -0600
  6. Organization: Digital Equipment Corporation Japan , Tokyo
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4fvgvb$e0t@solutions.solon.com>
  10. References: <4fstj7$2l6@solutions.solon.com>
  11. Reply-To: diamond@jrdv04.enet.dec-j.co.jp (Norman Diamond)
  12. NNTP-Posting-Host: solutions.solon.com
  13.  
  14. In article <4fstj7$2l6@solutions.solon.com>, Rune Huseby <rune.huseby@gpi.telemax.no> writes:
  15. >short test(short x1, short x2) {
  16. >  short result;
  17. >  result = x1 + x2;  /* Warning:  '=' : conversion from 'int '
  18. >                         to 'short ', possible loss of data */
  19. >My compiler [...] automagically converts my short-parameters to int's
  20.  
  21. No.  The addition operator "+" converts your short operands to ints.
  22.  
  23. The standard added the ability to prototype functions and clarified what
  24. would happen if parameters are declared with non-promoted types, and this
  25. is obeyed here.  It just happens to be irrelevant.  The "+" operator
  26. promoted its operands even in pre-standard days.
  27. --
  28.  <<  If this were the company's opinion, I would not be allowed to post it.  >>
  29. "I paid money for this car, I pay taxes for vehicle registration and a driver's
  30. license, so I can drive in any lane I want, and no innocent victim gets to call
  31. the cops just 'cause the lane's not goin' the same direction as me" - J Spammer
  32.